<?php 
class Usertoos
{
	////判断是否导出
	public  function pdsfxz($zf)
	{
		$pdymy=explode($zf,$_COOKIE['jrsc']);
		if (count($pdymy)>1)
		{
			return "checked";
		}
	}
	/**
	 * 图片转64位
	 * @param unknown_type $file
	 * @return string
	 */
	function imageToBase64($file)
	{
		if (file_exists($file))
		{
			$fp=fopen($file,"r");
			$type=getimagesize($file);//取得图片的大小，类型等
			$file_content=chunk_split(base64_encode(fread($fp,filesize($file))));//base64编码
			switch($type[2]){//判读图片类型
				case 1:$img_type="gif";break;
				case 2:$img_type="jpg";break;
				case 3:$img_type="png";break;
			}
			fclose($fp);
			return 'data:image/'.$img_type.';base64,'.$file_content;
		}
		else 
		{
			
			return "";
		}
	}
	/**
	 * 导出文件
	 * @param unknown_type $lb
	 * @param unknown_type $wjma
	 * @return string
	 */
	function derivedFile($lb,$filePath,$fileName)
	{
		$toos = new toos();
		$toos->createFolder($filePath);
		$fp = fopen($filePath.$fileName, 'w');
		fwrite($fp,$lb);
		fclose($fp);
		return $filePath.$fileName;
	}
	/**
	 * 下载文件
	 * @param unknown_type $file
	 */
	function download($file)
	{
		if (file_exists($file))
		{
			
			header('Content-Description: File Transfer');
			header('Content-Type: application/octet-stream');
			header('Content-Disposition: attachment; filename='.basename($file));
			header('Content-Transfer-Encoding: binary');
			header('Expires: 0');
			header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
			header('Pragma: public');
			header('Content-Length: ' . filesize($file));
			ob_clean();
			flush();
			readfile($file);
		}
	}
}

?>